// 方式二
// 双指针
// 时间：92
function maxArea(height) {
  let end = height.length - 1;
  let start = 0;
  let res = 0;
  while (start < end) {
    const x = end - start;
    let h = 0;
    if (height[start] > height[end]) {
      h = height[end];
      end--;
    } else {
      h = height[start];
      start++;
    }
    res = Math.max(h * x, res);
  }
  return res;
}

console.log(maxArea([1, 2, 3, 4, 5]));
